home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1985 October / Ahoy_Magazine_85-10_1985_Double_L.d64 / molecular mot. (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  1KB  |  45 lines

  1. 0 rem << rr22-1 >>
  2. 1 rem
  3. 2 rem -- molecular motion --
  4. 3 rem    rupert report #22
  5. 4 rem
  6. 6 rem movement of molecules from one
  7. 7 rem compartment to another
  8. 8 rem
  9. 9 :rem  total # and # on left side:
  10. 10 ttl=480 : nl=480
  11. 15 l1$=chr$(157):l$=" "+l1$+l1$+" "
  12. 20 kk=1 : k1=1024 : k2=40
  13. 30 k3=32 : k4=81  :rem blank & molecule
  14. 35 :rem  clear screen and set color:
  15. 40 poke 53281,0 : print chr$(147)
  16. 50 poke 53281,1 : print chr$(144)
  17. 55 :rem  put 480 molecules on left:
  18. 60 for y=1 to 24 : for x=0 to 19
  19. 70 poke k1+x+k2*y,k4 : next : next
  20. 75 :rem  ====  main loop ====
  21. 80 rl=nl/ttl :rem relative # on left
  22. 90 rn=rnd(0) :rem random number
  23. 100 if nl=480 and kk=-1 then 270
  24. 110 if rn<rl then pl=k3: pr=k4:goto 130
  25. 120 pl=k4 : pr=k3
  26. 130 x=int(rnd(0)*20):y=int(rnd(0)*24)+1
  27. 135 rem   memory locations to poke
  28. 140 ml=k1+x+y*k2
  29. 150 mr=k1+(20+x)+y*k2
  30. 160 get a$ : if a$<>"" then 270
  31. 165 rem  find location to 'unpoke'
  32. 170 if peek(ml)<>pl then 210
  33. 180 y=y+1 : if y<25 then 140
  34. 190 y=1 : x=x+1 : if x<20 then 140
  35. 200 x=0 : goto 140
  36. 210 if pl=k3 then nl=nl-kk : goto 230
  37. 220 nl=nl+kk
  38. 230 nr=ttl-nl : t=t+1
  39. 240 poke ml,pl : poke mr,pr
  40. 250 print chr$(19);nl;tab(17);"t=";kk*t;l$;tab(34);nr;l$
  41. 260 goto 80
  42. 265 rem   reverse the arrow of time
  43. 270 kk=-kk : temp=k3 : k3=k4 : k4=temp
  44. 280 t=0 : goto 80
  45.